const MS = require('./ms')
const request = require("./request.js")
const Error = require('./error')
const storage = require("./storage.js")
const {
    isObject,
    isString,
    isNumber,
    isUndefined,
    isArray
} = require('./dataType')


const imageText = class imageText {

  constructor() {

  }

  query(options) {
    let params = {
      pageNum: 1,
      pageSize: 10
    }

    if(isNumber(options.pageSize)) {
      params.pageSize = options.pageSize
    }
    if(isNumber(options.pageNum)) {
      params.pageNum = options.pageNum
    }
    if(isString(options.title)) {
      params.title = options.title
    }
    if(isNumber(options.category)) {
      params.category = options.category
    }
    return new Promise((resolve, reject) => {
      request(MS._config.parameters.IMAGE_TEXT.FIND_IMAGE_TEXT.url ,
          MS._config.parameters.IMAGE_TEXT.FIND_IMAGE_TEXT.method, params, {}).then(res => {
        resolve(res.data)
      }).catch(err => {
        reject(err)
      })
    })
  }

}

module.exports = imageText

